﻿<!--

Copyright (c) 2010 Stephen P Ward and Joseph E Feser

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
-->
<Window x:Class="Examples.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:conv="clr-namespace:Examples.Infrastructure"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Examples"
        xmlns:auto="clr-namespace:FeserWard.Controls;assembly=IntelliBox"
    xmlns:cal="http://www.caliburnproject.org"
    x:Name="mainWin"
        Title="Usage examples for the Intellibox"
        WindowStartupLocation="CenterScreen"
        Width="709"
        Height="500"
        Margin="6">
    <Control.Resources>
        <ResourceDictionary>
            <conv:CurrencyConverter x:Key="CurrencyConverter" />
        </ResourceDictionary>
    </Control.Resources>

    <TabControl TabStripPlacement="Bottom">
        <TabItem Header="Examples" DataContext="{Binding Examples}">
            <TabControl TabStripPlacement="Left">
                <TabItem Header="No Search Results"
                 ToolTip="Shows what happens when no search results are avalable.">
                    <StackPanel>
                        <TextBlock>Type anything.</TextBlock>
                        <TextBlock>This example shows what happens when no search results are available.</TextBlock>
                        <local:BasicSearchResultsCtrl DataContext="{Binding NoResultsVM}" />
                    </StackPanel>
                </TabItem>

                <TabItem Header="Single Column List"
                 ToolTip="Demonstrates displaying a single-column list of simple Types.">
                    <StackPanel>
                        <TextBlock>Type any of the letters of the alphabet 'a' through 'z' (lowercase).</TextBlock>
                        <TextBlock>This example demonstrates a provider that returns a single-column results list of a built in type.</TextBlock>
                        <local:BasicSearchResultsCtrl DataContext="{Binding SingleColumnVM}" />
                    </StackPanel>
                </TabItem>

                <TabItem Header="Limiting result set"
                         ToolTip="Demonstrates how to limit the maximum number of results returned by a search.">

                    <StackPanel>
                        <TextBlock>Type any of the letters of the alphabet 'a' through 'z' (lowercase).</TextBlock>
                        <TextBlock>This example demonstrates how to change the maximum number of results the IntelliBox asks for.</TextBlock>
                        <local:LimitedResultsCtrl DataContext="{Binding LimitingResultsVM}" />
                    </StackPanel>
                </TabItem>

                <TabItem Header="Multi-Column List"
                         ToolTip="Demonstrates displaying a multi-column list of simple Types."
                         DataContext="{Binding MultipleColumnVM}">
                    <StackPanel>
                        <TextBlock>Type anything. The provider in this example always returns the same result set.</TextBlock>
                        <TextBlock>This example demonstrates how, without any configuration, the IntelliBox does</TextBlock>
                        <TextBlock>something reasonable with a multi-column result set.</TextBlock>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=multiColumn, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                Width="200" Grid.Row="5" Grid.Column="2" 
                                Name="multiColumn"
                                SelectedItem="{Binding SelectedItem}"
                                SelectedValue="{Binding SelectedValue}"
                                DisplayedValueBinding="{Binding FirstName}"
                                SelectedValueBinding="{Binding PersonID}"
                                DataProvider="{Binding QueryProvider}">

                            </auto:Intellibox>
                        </Grid>
                    </StackPanel>
                </TabItem>

                <TabItem 
                    Header="Customizing Columns"
                    ToolTip="Demonstrates how to override the header title and width of specific columns, while leaving the others untouched."
                    DataContext="{Binding CustomizingColumnsVM}">
                    <StackPanel>
                        <TextBlock>Type anything. The provider in this example always returns the same result set.</TextBlock>
                        <TextBlock>This example demonstrates how to hide or change the width of some columns</TextBlock>
                        <TextBlock>without having to deal with all the columns in the result set. As a bonus! this</TextBlock>
                        <TextBlock>example also demonstrates how easy it is to bind the selected value and the</TextBlock>
                        <TextBlock>value displayed in the edit field to different columns.</TextBlock>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=overrideColumn, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                    Width="200" Grid.Row="5" Grid.Column="2" 
                                    Name="overrideColumn"
                                    SelectedItem="{Binding SelectedItem}"
                                    SelectedValue="{Binding SelectedValue}"
                                    DisplayedValueBinding="{Binding FirstName}"
                                    SelectedValueBinding="{Binding PersonID}"
                                    DataProvider="{Binding QueryProvider}">
                                <auto:Intellibox.Columns>
                                    <auto:IntelliboxColumn ForProperty="Age"
                                                   Width="125"
                                                   Header="Person's Age" />
                                    <auto:IntelliboxColumn ForProperty="PersonID"
                                                   Hide="True" />
                                </auto:Intellibox.Columns>
                            </auto:Intellibox>
                        </Grid>

                        <!-- -->
                        <!-- this one shows how to explicitly specify columns when you're interested in not showing most of the columns -->
                        <!-- -->

                        <TextBlock />
                        <TextBlock>Type anything. The provider in this example always returns the same result set.</TextBlock>
                        <TextBlock>This example demonstrates how to make the IntelliBox show only the columns that you</TextBlock>
                        <TextBlock>want it to show. As a bonus! it also demonstrates that you can bind the selected value</TextBlock>
                        <TextBlock>to a column that isn't being shown.</TextBlock>
                        <TextBlock />

                        <StackPanel Orientation="Horizontal">
                            <TextBlock>Selected Value:</TextBlock>
                            <TextBlock Text="{Binding ElementName=overrideAllColumn, Path=SelectedValue}" />
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock>Selected Item:</TextBlock>
                            <TextBlock Text="{Binding ElementName=overrideAllColumn, Path=SelectedItem}" />
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <TextBlock>Highlighted Value:</TextBlock>
                            <TextBlock Name="four"
                               Text="{Binding ElementName=overrideAllColumn, Path=DisplayTextFromHighlightedItem}" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock VerticalAlignment="Center"
                               Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox Width="200" 
                                     Name="overrideAllColumn"
                                     DisplayedValueBinding="{Binding FirstName}"
                                     SelectedValueBinding="{Binding PersonID}"
                                     ExplicitlyIncludeColumns="True"
                                     DataProvider="{Binding QueryProvider}">
                                <auto:Intellibox.Columns>
                                    <auto:IntelliboxColumn DisplayMemberBinding="{Binding FirstName}"
                                                   Width="150"
                                                   Header="First Name" />
                                    <auto:IntelliboxColumn DisplayMemberBinding="{Binding LastName}"
                                                   Width="75"
                                                   Header="Last Name" />
                                </auto:Intellibox.Columns> 
                            </auto:Intellibox>
                        </StackPanel>

                    </StackPanel>
                </TabItem>


                <TabItem 
                    Header="Altering Column Position"
                    ToolTip="Demonstrates how to alter the natural position of the displayed columns."
                    DataContext="{Binding ChangeColumnPositionVM}">

                    <StackPanel>

                        <TextBlock>Type anything. The provider in this example always returns the same result set.</TextBlock>
                        <TextBlock>This example demonstrates how to use the 'Position' property to change the</TextBlock>
                        <TextBlock>default positioning and order of columns in a multi-column result set.</TextBlock>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=positionColumn, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                Width="200" Grid.Row="5" Grid.Column="2" 
                                Name="positionColumn"
                                SelectedItem="{Binding SelectedItem}"
                                SelectedValue="{Binding SelectedValue}"
                                DisplayedValueBinding="{Binding FirstName}"
                                SelectedValueBinding="{Binding PersonID}"
                                DataProvider="{Binding QueryProvider}">

                                <auto:Intellibox.Columns>
                                    <auto:IntelliboxColumn ForProperty="Weight"
                                                   Position="2" />
                                    <auto:IntelliboxColumn ForProperty="Age"
                                                   Position="1" />
                                    <auto:IntelliboxColumn ForProperty="NetWorth"
                                                   Position="3" />
                                </auto:Intellibox.Columns>
                            </auto:Intellibox>
                        </Grid>
                    </StackPanel>

                </TabItem>

                <TabItem 
                    Header="Multi-Column Northwind Product DB"
                    ToolTip="Demonstrates displaying a multi-column list of simple Types returned from a database provider."
                    DataContext="{Binding ORMExampleVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">This example shows how you can use an ORM like LightSpeed to query                a database and return results.</TextBlock>
                        <TextBlock>Product Search</TextBlock>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=lightspeedBox, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                Width="200" Grid.Row="5" Grid.Column="2" 
                                ResultsHeight="110"
                                ExplicitlyIncludeColumns="True"
                                Name="lightspeedBox"
                                SelectedItem="{Binding SelectedItem}"
                                SelectedValue="{Binding SelectedValue}"
                                DisplayedValueBinding="{Binding ProductName}"
                                SelectedValueBinding="{Binding ProductId}"
                                DataProvider="{Binding QueryProvider}">
                                <auto:Intellibox.Columns>
                                    <auto:IntelliboxColumn DisplayMemberBinding="{Binding ProductName}"
                                                   Width="150"
                                                   Header="Product Name" />
                                    <auto:IntelliboxColumn DisplayMemberBinding="{Binding UnitPrice, Converter={StaticResource CurrencyConverter}}"
                                                   Width="75"
                                                   Header="Unit Price" />
                                    <auto:IntelliboxColumn DisplayMemberBinding="{Binding Supplier.CompanyName}"
                                                   Width="125"
                                                   Header="Supplier" />
                                </auto:Intellibox.Columns>
                            </auto:Intellibox>
                        </Grid>
                    </StackPanel>
                </TabItem>

                <TabItem 
                    Header="Setting Search Frequency"
                    ToolTip="Demonstrates how to control the frequency of the SearchBeginning event"
                    DataContext="{Binding SearchFrequencyVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">This example shows how to reduce contention on the backing data storage
                by changing the default time interval between searches and the minimum number of characters needed to start a search.</TextBlock>
                        <TextBlock>Enter any character from a-z to start searching.</TextBlock>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding DelayedSearch.SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding DelayedSearch.SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=searchDelayBox, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                Width="200" Grid.Row="5" Grid.Column="2" 
                                Name="searchDelayBox"
                                SelectedItem="{Binding DelayedSearch.SelectedItem}"
                                SelectedValue="{Binding DelayedSearch.SelectedValue}"
                                MinimumSearchDelay="1000"
                                MinimumPrefixLength="1"
                                DataProvider="{Binding DelayedSearch.QueryProvider}"/>

                            <TextBlock Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="3" >Search begun notifications</TextBlock>
                            <ListView  Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="3" Width="200" Height="250" HorizontalAlignment="Left"
                                ItemsSource="{Binding SearchNotifications}" />
                        </Grid>
                    </StackPanel>
                </TabItem>

                <TabItem 
                    Header="Searches that take a long time"
                    ToolTip="Demonstrates how to tell the Intellibox to show the 'waiting for results' message."
                    DataContext="{Binding LengthySearchesVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">This example shows how to tell the Intellibox control what an excessively long search
                        is considered to be. After the first search has taken longer than the 'excessively long' time to return, the Intellibox
                        will show a form with a "Searching..." message and a cancel button.</TextBlock>

                        <TextBlock>Enter any character from a-z to start searching.</TextBlock>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding LongSearch.SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding LongSearch.SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=resultsDelayedBox, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                Width="200" Grid.Row="5" Grid.Column="2" 
                                Name="resultsDelayedBox"
                                SelectedItem="{Binding LongSearch.SelectedItem}"
                                SelectedValue="{Binding LongSearch.SelectedValue}"
                                TimeBeforeWaitNotification="100"
                                DataProvider="{Binding LongSearch.QueryProvider}"/>

                            <TextBlock Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="3" >Search begun notifications</TextBlock>
                            <ListView  Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="3" Width="200" Height="250" HorizontalAlignment="Left"
                                ItemsSource="{Binding SearchNotifications}" />
                        </Grid>
                    </StackPanel>
                </TabItem>

                <TabItem 
                    Header="Showing Watermark text"
                    ToolTip=""
                    DataContext="{Binding WatermarkVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">
                            Demonstrates how to use the WatermarkText (and associated properties) to show a short
                            message to the user when the Intellibox doesn't have any content.
                        </TextBlock>

                        <TextBox Text="This is a normal textbox. Notice how you can remove this text just by selecting and deleting it"
                                 TextWrapping="Wrap"/>

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="20px" />
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="10px" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>

                            <TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Right">Selected Value:</TextBlock>
                            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding SelectedValue}" />

                            <TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Right">Selected Item:</TextBlock>
                            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding SelectedItem}" />

                            <TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Right">Highlighted Value:</TextBlock>
                            <TextBlock Grid.Row="3" Grid.Column="2" Text="{Binding ElementName=watermarkBox, Path=DisplayTextFromHighlightedItem}" />

                            <TextBlock Grid.Row="5" Grid.Column="0" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,6,0">Search:</TextBlock>
                            <auto:Intellibox 
                                Width="200" Grid.Row="5" Grid.Column="2" 
                                Name="watermarkBox"
                                SelectedItem="{Binding SelectedItem}"
                                SelectedValue="{Binding SelectedValue}"
                                WatermarkText="Results begin with a-z"
                                WatermarkBackground="AliceBlue"
                                WatermarkForeground="Black"
                                DataProvider="{Binding QueryProvider}" />

                        </Grid>
                    </StackPanel>
                </TabItem>
            </TabControl>

        </TabItem>

        <!---->
        <!---->

        <!-- The test tab -->

        <!---->
        <!---->

        <TabItem Header="Functional Tests"
                 DataContext="{Binding Tests}">
            <TabControl TabStripPlacement="Left">
                <TabItem Header="Empty 'Path'"
                         ToolTip="Bug: empty 'path' specifier in DisplayedValueBinding causes an exception."
                         DataContext="{Binding EmptyPathTestVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">
                            Bug: empty 'path' specifier in DisplayedValueBinding causes an exception.
                            <LineBreak />
                            http://intellibox.codeplex.com/WorkItem/View.aspx?WorkItemId=3993
                        </TextBlock>

                        <TextBlock />

                        <TextBlock>
                            Type any english alphabet character to get a list of results.
                            <LineBreak />
                            You should see the value of the selected row in textbox.
                        </TextBlock>

                        <TextBlock />

                        <auto:Intellibox Width="200"
                                         HorizontalAlignment="Left"
                                         DisplayedValueBinding="{Binding}"
                                         DataProvider="{Binding QueryProvider}" />
                    </StackPanel>
                </TabItem>


                <TabItem Header="ValueConverters"
                         ToolTip="makes sure ValueConverters on the DisplayedValueBinding work correctly"
                         DataContext="{Binding ValueConvertersTestVM}">
                    <StackPanel>
                        <StackPanel.Resources>
                            <conv:AppendTextConverter x:Key="appendingText" />
                        </StackPanel.Resources>
                        <TextBlock TextWrapping="Wrap">
                            The intellibox should be able to handle ValueConverters on the DisplayedValueBinding property.
                            <LineBreak />
                            Motivated by: http://intellibox.codeplex.com/WorkItem/View.aspx?WorkItemId=3993
                        </TextBlock>

                        <TextBlock />

                        <TextBlock>
                            Type any english alphabet character to get a list of results.
                            <LineBreak />
                            You should see the characters 'ABCDEF' after the value in the textbox.
                        </TextBlock>

                        <TextBlock />

                        <auto:Intellibox Width="200"
                                         HorizontalAlignment="Left"
                                         DisplayedValueBinding="{Binding Converter={StaticResource appendingText}, ConverterParameter=ABCDEF}"
                                         DataProvider="{Binding QueryProvider}" />
                    </StackPanel>
                </TabItem>

                <TabItem Header="SelectedItem OneWayToSourceBinding"
                         ToolTip="makes sure that the SelectedItem property supports a standard OneWayToSource binding"
                         DataContext="{Binding OneWayToSourceTestVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">
                            The intellibox should be able to handle twoway bindings from the SelectedValue property
                            to a property on the data source object.
                            <LineBreak />
                            Motivated by: http://intellibox.codeplex.com/WorkItem/View.aspx?WorkItemId=3994
                        </TextBlock>

                        <TextBlock />

                        <TextBlock>
                            Type anything. The same list of results is always returned.
                            <LineBreak />
                            The value shown in the 'FirstName' field should match the value shown in the textbox.
                        </TextBlock>

                        
                        <TextBlock />

                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Text="First Name: " />
                            <TextBlock Text="{Binding Path=PersonObjectForOneWay.FirstName}" />
                        </StackPanel>

                        <TextBlock />

                        <auto:Intellibox Width="200"
                                         HorizontalAlignment="Left"
                                         DisplayedValueBinding="{Binding FirstName}"
                                         SelectedItem="{Binding Path=PersonObjectForOneWay, Mode=OneWayToSource}"
                                         ResultsMaxHeight="150"
                                         DataProvider="{Binding Path=QueryProvider}" />
                    </StackPanel>
                </TabItem>

                <TabItem Header="SelectedValue OneWayToSource"
                         ToolTip="makes sure that the SelectedValue property supports a OneWayToSource binding"
                         DataContext="{Binding OneWayToSourceTestVM}">
                    <StackPanel>
                        <TextBlock TextWrapping="Wrap">
                            The intellibox should be able to handle OneWayToSource bindings from the SelectedValue property to
                            the data source object.
                            <LineBreak />
                            Motivated by: http://intellibox.codeplex.com/WorkItem/View.aspx?WorkItemId=3994
                        </TextBlock>

                        <TextBlock />

                        <TextBlock>
                            Type anything. The same list of results is always returned.
                            <LineBreak />
                            The value shown in the 'FirstName' field should match the value shown in the textbox.
                        </TextBlock>

                        <TextBlock />

                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Text="First Name: " />
                            <TextBlock Text="{Binding Path=PersonFirstNameForOneWay}" />
                        </StackPanel>

                        <TextBlock />

                        <auto:Intellibox
                                         HorizontalAlignment="Left"
                                         DisplayedValueBinding="{Binding FirstName}"
                                         SelectedValue="{Binding Path=PersonFirstNameForOneWay, Mode=OneWayToSource}"
                                         SelectedValueBinding="{Binding Path=FirstName}"
                                         ResultsMaxHeight="150"
                                         DataProvider="{Binding Path=QueryProvider}" />
                    </StackPanel>
                </TabItem>
                <TabItem Header="work item 4391"
                         ToolTip="test to make sure the problem in work item in 4391 is fixed"
                         DataContext="{Binding WorkItem4391TestVM}">
                    <StackPanel>
                        <TextBlock>
                            the control should display and 3 rows should always display in the result list, although
                            those rows will be blank.
                        </TextBlock>
                        <auto:Intellibox ResultsMaxHeight="150"
                                         DataProvider="{Binding Path=QueryProvider}" />
                    </StackPanel>
                </TabItem>

                <TabItem Header="work item 5544"
                         x:Name="tbIssue5544TestTab"
                         ToolTip="test to make sure the problem in work item 5544 is fixed"
                         DataContext="{Binding WorkItem5544TestVM}">
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button x:Name="SwapDataContexts" Content="swap datacontexts" cal:Message.Attach="[Event Click] = [Action SwapDataContexts()];" />
                        </StackPanel>

                        <local:Issue5544TestControl />

                    </StackPanel>

                </TabItem>

                <TabItem Header="work item 6309"
                         ToolTip="test to make sure the result list recalculates column widths"
                         DataContext="{Binding WorkItem6309TestVM}">
                    <StackPanel>
                        <TextBlock >
                            To run this test, first type 'a' into the control; this will return a narrow result set.<LineBreak />
                            Select a value, then close the result list. Next type 'z' into the control, this will return<LineBreak />
                            a wide result set. Verify that the column widths in the result set have been recalculated.<LineBreak />
                        </TextBlock>

                        <auto:Intellibox
                            DataProvider="{Binding Path=QueryProvider}"
                            DisplayedValueBinding="{Binding Name}"/>

                    </StackPanel>

                </TabItem>

                <TabItem Header="work item 6036"
                         ToolTip="test of the new File Path Picker implementation"
                         DataContext="{Binding WorkItem6036TestVM}">
                    <StackPanel>
                        <TextBlock>

                        </TextBlock>

                        <Label Content="Only returns directories matching the search term" />
                        <auto:Intellibox
                            DataProvider="{Binding Path=DirectoryOnlySearch.QueryProvider}"
                            />

                        <Label Content="Only returns files matching the search term" />
                        <auto:Intellibox
                            DataProvider="{Binding Path=FileOnlySearch.QueryProvider}"
                            />

                        <Label Content="Returns both files and directories matching the search term" />
                        <auto:Intellibox
                            DataProvider="{Binding Path=FileAndDirectorySearch.QueryProvider}"
                            />
                    </StackPanel>
                </TabItem>
                
                <TabItem Header="work item 6308"
                         ToolTip="test for updating the search box text when the SelectedItem is changed via databinding"
                         DataContext="{Binding WorkItem6308TestVM}">
                    <StackPanel>
                        <TextBlock>
                            Type any letter of the alphabet to start, and then select an item from the result list.
                            Once an item is selected, click the button on this tab. If the text in the intellibox changes
                            to an 'A' (or a 'Z' if an 'A' was already selected), then this test passes. Otherwise, it fails.
                        </TextBlock>

                        <StackPanel Orientation="Horizontal">
                            <Label Content="MyItem value: " />
                            <TextBox Text="{Binding MyItem, Mode=OneWay}" />
                        </StackPanel>
                        
                        <Button x:Name="ChangeSearchText" Content="Change the SearchText" cal:Message.Attach="[Event Click] = [Action ChangeMyItem()];" />
                        
                        <auto:Intellibox
                            DataProvider="{Binding QueryProvider}"
                            SelectedItem="{Binding MyItem}"
                            />
                    </StackPanel>
                </TabItem>
                
                <TabItem Header="workitem 6310"
                         ToolTip="Test for closing the search results popup programmatically"
                         DataContext="{Binding WorkItem6310TestVM}">
                    <StackPanel>

                        <TextBlock>
                            Use the checkbox below to turn the selecting of single results on and off.
                        </TextBlock>
                        <CheckBox IsChecked="{Binding SelectSingleResult}">
                            Automatically select single results?
                        </CheckBox>
                        
                        <auto:Intellibox DataProvider="{Binding QueryProvider}" AutoSelectSingleResult="{Binding SelectSingleResult}" />
                    </StackPanel>
                    
                </TabItem>
                
            </TabControl>
        </TabItem>

    </TabControl>
</Window>
